home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / tgrind.zip / RETEST.C < prev    next >
C/C++ Source or Header  |  1990-09-18  |  1KB  |  67 lines

  1. #ifndef lint
  2. static char *sccsid="@(#)retest.c    1.1 (LBL) 3/29/85";
  3. #endif
  4.  
  5. #include <ctype.h>
  6.  
  7. int l_onecase = 0;
  8. char * _start;
  9. char * _escaped;
  10. char * convexp();
  11. char * expmatch();
  12. main()
  13. {
  14.     char reg[132];
  15.     char *ireg;
  16.     char str[132];
  17.     char *match;
  18.     char matstr[132];
  19.     char c;
  20.  
  21.     while (1) {
  22.     printf ("\nexpr: ");
  23.     scanf ("%s", reg);
  24.     ireg = convexp(reg);
  25.     match = ireg;
  26.     while(*match) {
  27.         switch (*match) {
  28.  
  29.         case '\\':
  30.         case '(':
  31.         case ')':
  32.         case '|':
  33.         printf ("%c", *match);
  34.         break;
  35.  
  36.         default:
  37.         if (isalnum(*match))
  38.             printf("%c", *match);
  39.         else
  40.             printf ("<%03o>", *match);
  41.         break;
  42.         }
  43.         match++;
  44.     }
  45.     printf("\n");
  46.     getchar();
  47.     while(1) {
  48.         printf ("string: ");
  49.         match = str;
  50.         while ((c = getchar()) != '\n')
  51.         *match++ = c;
  52.         *match = 0;
  53.         if (str[0] == '#')
  54.         break;
  55.         matstr[0] = 0;
  56.         _start = str;
  57.         _escaped = 0;
  58.         match = expmatch (str, ireg, matstr);
  59.         if (match == 0)
  60.         printf ("FAILED\n");
  61.         else
  62.         printf ("match\nmatstr = %s\n", matstr);
  63.     }
  64.  
  65.     }
  66. }
  67.